Skip to content

[material_ui] port drawer tests over from flutter/widgets - #12711

Open
navaronbracke wants to merge 1 commit into
flutter:mainfrom
navaronbracke:move_drawer_tests_from_flutterwidgets
Open

[material_ui] port drawer tests over from flutter/widgets#12711
navaronbracke wants to merge 1 commit into
flutter:mainfrom
navaronbracke:move_drawer_tests_from_flutterwidgets

Conversation

@navaronbracke

@navaronbracke navaronbracke commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This PR moves tests from packages/flutter under widgets/drawer_test.dart into material_ui.

Most tests were moved verbatim, except for a few tests that I renamed, because the test name was not very clear.
The drawer control tests for Material 2/3 that already existed were updated to test some additional behavior.

Part of flutter/flutter#177028

See flutter/flutter#192106 which removes the tests in flutter/flutter

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 1, 2026
@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Sep 1, 2026
state.openDrawer();

await tester.pump();
expect(find.text('Archive'), findsOneWidget);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


expect(find.text('header'), findsOneWidget);

Navigator.pop(savedContext);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ports drawer tests from flutter/widgets into material_ui, updating existing tests to verify drawer dismissal animations and adding several new tests covering tap, hover, gesture cancellation, and semantics behaviors. The review feedback suggests replacing hardcoded strings in the semantics tests (such as 'Dismiss' and 'Navigation menu') with localized values from DefaultMaterialLocalizations to make the tests robust against localization changes.

await tester.pump(const Duration(milliseconds: 100));

expect(semantics, includesNodeWith(actions: <SemanticsAction>[SemanticsAction.tap]));
expect(semantics, includesNodeWith(label: 'Dismiss'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using the hardcoded string 'Dismiss' for the semantics label. Instead, use const DefaultMaterialLocalizations().modalBarrierDismissLabel to ensure the test is robust against localization changes and matches the implementation's localized values.

Suggested change
expect(semantics, includesNodeWith(label: 'Dismiss'));
expect(semantics, includesNodeWith(label: const DefaultMaterialLocalizations().modalBarrierDismissLabel));

includesNodeWith(actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus]),
),
);
expect(semantics, isNot(includesNodeWith(label: 'Dismiss')));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using the hardcoded string 'Dismiss' for the semantics label. Instead, use const DefaultMaterialLocalizations().modalBarrierDismissLabel to ensure the test is robust against localization changes and matches the implementation's localized values.

Suggested change
expect(semantics, isNot(includesNodeWith(label: 'Dismiss')));
expect(semantics, isNot(includesNodeWith(label: const DefaultMaterialLocalizations().modalBarrierDismissLabel)));

Comment on lines +1398 to +1404
expect(
semantics,
includesNodeWith(
label: 'Navigation menu',
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute],
),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using the hardcoded string 'Navigation menu' for the semantics label. Instead, use const DefaultMaterialLocalizations().drawerLabel to ensure the test is robust against localization changes and matches the implementation's localized values.

Suggested change
expect(
semantics,
includesNodeWith(
label: 'Navigation menu',
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute],
),
);
expect(
semantics,
includesNodeWith(
label: const DefaultMaterialLocalizations().drawerLabel,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute],
),
);

testWidgets('Material3 - Drawer control test', (WidgetTester tester) async {
const containerKey = Key('container');

late BuildContext savedContext;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same changes as the test above were applied here, since we have the M2/M3 split

semantics.dispose();
}, variant: TargetPlatformVariant.only(TargetPlatform.android));

testWidgets('Drawer tap test', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved over verbatim

expect(find.text('drawer'), findsNothing);
});

testWidgets('Drawer hover test', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved over verbatim

expect(finder, findsNothing);
});

testWidgets('Close drawer with navigator pop', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(buttonPressed, equals(true));
});

testWidgets('Drawer closing can be canceled by gesture (LTR)', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await gesture.up();
});

testWidgets('Drawer closing can be canceled by gesture (RTL)', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this test

});

testWidgets(
'Dismissible Drawer includes button in semantic tree',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}),
);

testWidgets('Dismissible Drawer is hidden on Android (back button is used to dismiss)', (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await pumpDrawerWithTheme(TargetPlatform.iOS);
}, variant: TargetPlatformVariant.all());

testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved over verbatim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant